package com.cqyc.shop.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cqyc.shop.comm.Pager;
import com.cqyc.shop.comm.commException;
import com.cqyc.shop.domain.Shop;
import com.cqyc.shop.services.ShopServices;

@WebServlet(urlPatterns="/health/health.do")
public class HealthListServlet extends HttpServlet{
	private static final long serialVersionUID = 3831380498732237494L;
	private Logger logger = LoggerFactory.getLogger(getClass());
	private ShopServices shopServices = new ShopServices();
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			Shop shop = new Shop();
						
			Pager pager_yyys = new Pager();
			pager_yyys.setPageSize(16);
			pager_yyys.setCurrentPage(1);
			shop.setShopname("养生");
			
			List<Shop> shops_yyys = shopServices.findPager(shop,pager_yyys);

			request.setAttribute("shops_yyys",shops_yyys);
			
			
			
			Pager pager_rmtj = new Pager();
			pager_rmtj.setPageSize(3);
			pager_rmtj.setCurrentPage(7);
			shop.setShopname("养生");
			
			List<Shop> shops_rmtj = shopServices.findPager(shop,pager_rmtj);

			request.setAttribute("shops_rmtj",shops_rmtj);

			
			logger.debug("查询数据成功");
			request.getRequestDispatcher("/health/health.jsp").forward(request, response);
		} catch (Exception e) {
			throw new commException("list查找出现异常");
		}
	}
	

}
